package com.atguigu.datastream.test.day03;

import org.apache.flink.api.java.io.TextInputFormat;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.FileProcessingMode;

/**
 * ClassName: Flink_02_Source_File
 * Package: com.atguigu.test.day03
 * Description:
 *
 * @Author ChenJun
 * @Create 2023/4/9 19:05
 * @Version 1.0
 */
public class Flink_02_Source_File {
    public static void main(String[] args) throws Exception {

        // 1.创建流的执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //2. 设置并行度
        env.setParallelism(1);

        //3. 从文件读取数据
//        DataStreamSource<String> streamSource = env.readTextFile("input/word.txt");
        DataStreamSource<String> streamSource = env.readFile(new TextInputFormat(new Path()), "input/word.txt", FileProcessingMode.PROCESS_CONTINUOUSLY, 200);


        //4. 打印
        streamSource.print();

        //5. 执行
        env.execute();
    }
}
